CaseExpression.Simple case

Selects one from a number of alternate values

Format

CASE expression [ WHEN expression THEN expression ]* [ ELSE expression ] END

Remarks

The simple case condition consists of a selector expression, one or more WHEN ... END clauses, and a last resort ELSE clause.

The selector expression is evaluated, and the result used to match agains the expression associated with each WHEN condition in the order as written. As soon as a match is found, the value of the corresponding THEN expression is taken as the overall result. If none of the WHEN clauses match, the overall result is taken from the expression associated with the ELSE clause.

Example:

CASE AlarmState

WHEN 4 THEN 'Unaccepted Alarm'

WHEN 3 THEN 'Cleared Alarm'

WHEN 2 THEN 'Accepted Alarm'

WHEN 1 THEN 'Disabled Alarm'

WHEN 0 THEN 'No Alarm'

ELSE 'Unknown Alarm State'

END


Disclaimer

Geo SCADA Expert 2020